package com.gzyj.server.utils;

/**
 * @author lhj
 */
public class StackUtils {

    public static String getStackInfo(Exception e) {
        // Get the stack trace of the exception
        StackTraceElement[] stackTrace = e.getStackTrace();

// Convert the stack trace to a string
        StringBuilder sb = new StringBuilder();
        for (StackTraceElement element : stackTrace) {
            sb.append(element.toString()).append("\n");
        }
        String stackTraceString = sb.toString();
        return stackTraceString;
    }

    public static String getStackInfo(Throwable e) {
        // Get the stack trace of the exception
        StackTraceElement[] stackTrace = e.getStackTrace();

// Convert the stack trace to a string
        StringBuilder sb = new StringBuilder();
        for (StackTraceElement element : stackTrace) {
            sb.append(element.toString()).append("\n");
        }
        String stackTraceString = sb.toString();
        return stackTraceString;
    }
}
